package com.esun.payment_api.controller;

import com.esun.common.api.CommonPage;
import com.esun.common.api.CommonResult;
import com.esun.common.utils.SecurityUtils;
import com.esun.payment_api.dao.DkReceiveDao;
import com.esun.payment_api.dto.DkReceiveQueryParam;
import com.esun.payment_api.security.model.LoginUser;
import com.esun.payment_api.service.DkReceiveService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/receive")
public class DkReceiveController extends BaseController{

    @Autowired
    private DkReceiveService dkReceiveService;

    @ApiOperation("到款-银行到款列表")
    @GetMapping("/list")
    public CommonResult<CommonPage<DkReceiveDao>> queryList(DkReceiveQueryParam queryParam,
                                @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
        try{
            LoginUser loginUser = getLoginUser();
            queryParam.setDeptId(loginUser.getDeptId());
            System.out.println("(loginUser.getDeptId():"+loginUser.getDeptId()+":");
        }catch (Exception e){
            e.printStackTrace();
        }

        List<DkReceiveDao> list = dkReceiveService.getList(queryParam, pageSize, pageNum);
        //
        //System.out.println(loginUser.getUsername());
        return CommonResult.success(CommonPage.restPage(list));
    }

    @ApiOperation("到款-银行到款详情")
    @GetMapping("/getById")
    public CommonResult<DkReceiveDao> getById(Integer id){
        return CommonResult.success(dkReceiveService.getDkReceiveById(id));
    }

}
